/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bs.views;

import com.bs.beans.Banco;
import java.util.ArrayList;

/**
 *
 * @author Bone
 */
public class BancoView extends javax.swing.JPanel {
    

    /**
     * Creates new form BancoDetalhe
     */
    public BancoView() {
        super();
        initComponents();
        bancoGridController.getParametros().add(nomePesquisa);
        
    } 

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        bindingGroup = new org.jdesktop.beansbinding.BindingGroup();

        entityManager = new com.bs.persistencia.EntityManager();
        list = org.jdesktop.observablecollections.ObservableCollections.observableList(new ArrayList<Banco>());
        banco = new com.bs.beans.Banco();
        bancoGridController = new com.bs.controllers.BancoGridController<com.bs.beans.Banco>();
        jScrollPane1 = new javax.swing.JScrollPane();
        bancoTable = new javax.swing.JTable();
        atualizarButton = new com.bs.extensoesSwing.AtualizarGridButton();
        alterarRegistroGridButton1 = new com.bs.extensoesSwing.AlterarRegistroGridButton();
        novoRegistroGridButton1 = new com.bs.extensoesSwing.NovoRegistroGridButton();
        excluirRegistroGridButton1 = new com.bs.extensoesSwing.ExcluirRegistroGridButton();
        tituloFormulario1 = new com.bs.extensoesSwing.TituloFormulario();
        jPanel1 = new javax.swing.JPanel();
        nomePesquisa = new com.bs.pesquisaView.PesquisaTexto();
        jLabel1 = new javax.swing.JLabel();
        campoNumericoInteiro1 = new com.bs.extensoesSwing.CampoNumericoInteiro();
        filtrarRegistroGridButton1 = new com.bs.extensoesSwing.FiltrarRegistroGridButton();

        bancoGridController.setClasse(banco);
        bancoGridController.setEntityManager(entityManager);
        bancoGridController.setLimiteRegistros(150);
        bancoGridController.setLista(list);

        org.jdesktop.beansbinding.Binding binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, bancoTable, org.jdesktop.beansbinding.ELProperty.create("${selectedElement}"), bancoGridController, org.jdesktop.beansbinding.BeanProperty.create("beanSelecionado"));
        bindingGroup.addBinding(binding);
        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, bancoTable, org.jdesktop.beansbinding.ELProperty.create("${selectedElement.id}"), bancoGridController, org.jdesktop.beansbinding.BeanProperty.create("idBeanSelecionado"));
        binding.setSourceNullValue(null);
        binding.setSourceUnreadableValue(null);
        bindingGroup.addBinding(binding);

        setName("Bancos"); // NOI18N

        bancoTable.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
        bancoTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);

        org.jdesktop.swingbinding.JTableBinding jTableBinding = org.jdesktop.swingbinding.SwingBindings.createJTableBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, list, bancoTable);
        org.jdesktop.swingbinding.JTableBinding.ColumnBinding columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${numero} "));
        columnBinding.setColumnName("Numero");
        columnBinding.setEditable(false);
        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${nomeBanco}"));
        columnBinding.setColumnName("Nome Banco");
        columnBinding.setColumnClass(String.class);
        columnBinding.setEditable(false);
        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${site}"));
        columnBinding.setColumnName("Site");
        columnBinding.setColumnClass(String.class);
        columnBinding.setEditable(false);
        bindingGroup.addBinding(jTableBinding);
        jTableBinding.bind();
        jScrollPane1.setViewportView(bancoTable);
        bancoTable.getColumnModel().getColumn(0).setResizable(false);
        bancoTable.getColumnModel().getColumn(0).setPreferredWidth(70);
        bancoTable.getColumnModel().getColumn(1).setPreferredWidth(200);
        bancoTable.getColumnModel().getColumn(2).setPreferredWidth(300);

        atualizarButton.setController(bancoGridController);

        alterarRegistroGridButton1.setController(bancoGridController);

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, bancoTable, org.jdesktop.beansbinding.ELProperty.create("${selectedElement != null}"), alterarRegistroGridButton1, org.jdesktop.beansbinding.BeanProperty.create("enabled"));
        bindingGroup.addBinding(binding);

        novoRegistroGridButton1.setController(bancoGridController);

        excluirRegistroGridButton1.setController(bancoGridController);

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, bancoTable, org.jdesktop.beansbinding.ELProperty.create("${selectedElement != null}"), excluirRegistroGridButton1, org.jdesktop.beansbinding.BeanProperty.create("enabled"));
        bindingGroup.addBinding(binding);

        tituloFormulario1.setTitulo("Bancos");

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Filtro"));

        nomePesquisa.setCampo("nomeBanco");
        nomePesquisa.setLegenda("Nome:");

        jLabel1.setText("Limite de registros:");

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, bancoGridController, org.jdesktop.beansbinding.ELProperty.create("${limiteRegistros}"), campoNumericoInteiro1, org.jdesktop.beansbinding.BeanProperty.create("text"));
        binding.setSourceUnreadableValue(null);
        bindingGroup.addBinding(binding);

        filtrarRegistroGridButton1.setController(bancoGridController);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(nomePesquisa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(filtrarRegistroGridButton1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(campoNumericoInteiro1, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(filtrarRegistroGridButton1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel1)
                            .addComponent(campoNumericoInteiro1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(nomePesquisa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(17, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(tituloFormulario1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 692, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(novoRegistroGridButton1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(alterarRegistroGridButton1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(excluirRegistroGridButton1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(atualizarButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(tituloFormulario1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 220, Short.MAX_VALUE)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(atualizarButton, javax.swing.GroupLayout.DEFAULT_SIZE, 45, Short.MAX_VALUE)
                    .addComponent(alterarRegistroGridButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(novoRegistroGridButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(excluirRegistroGridButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );

        bindingGroup.bind();
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private com.bs.extensoesSwing.AlterarRegistroGridButton alterarRegistroGridButton1;
    private com.bs.extensoesSwing.AtualizarGridButton atualizarButton;
    private com.bs.beans.Banco banco;
    private com.bs.controllers.BancoGridController<com.bs.beans.Banco> bancoGridController;
    private javax.swing.JTable bancoTable;
    private com.bs.extensoesSwing.CampoNumericoInteiro campoNumericoInteiro1;
    private com.bs.persistencia.EntityManager entityManager;
    private com.bs.extensoesSwing.ExcluirRegistroGridButton excluirRegistroGridButton1;
    private com.bs.extensoesSwing.FiltrarRegistroGridButton filtrarRegistroGridButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private java.util.List<Banco> list;
    private com.bs.pesquisaView.PesquisaTexto nomePesquisa;
    private com.bs.extensoesSwing.NovoRegistroGridButton novoRegistroGridButton1;
    private com.bs.extensoesSwing.TituloFormulario tituloFormulario1;
    private org.jdesktop.beansbinding.BindingGroup bindingGroup;
    // End of variables declaration//GEN-END:variables
}
